package com.jiahao.utils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

public class HttpUtils {

    public static void doBgPostReq(HttpServletResponse response, String postUrl, Map<String,?> paramMap) throws IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.println("<form name='postSubmit' method='post' action='"+postUrl+"'>");
        for (String key : paramMap.keySet()){
            out.println("<input type='hidden' name='"+key+"' value='"+paramMap.get(key)+"'>");
        }
        out.println("</form>");
        out.println("<script>");
        out.println(" document.postSubmit.submit()");
        out.println("</script>");
    }
}
